package com.shirotest.utility;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.UUID;

/**
 * 字符串工具类
 */
public class StringUtility {
	/**
	 * 判断给定的字符串是否为空、空字符串或者空白符字符串
	 * @return
	 */
	public static boolean isEmpty(String source){
		if(source == null || source.trim().length() == 0){
			return true;
		}
		return false;
	}
	
	/**
	 * 获取32位UUID
	 */
	public static String getUUID(){
		return UUID.randomUUID().toString().replaceAll("-", "");
	}
	
	/**
	 * 获取异常的堆栈信息
	 * @param e
	 * @return
	 */
	public static String getStackTrace(Throwable e) {
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();  
		e.printStackTrace(new PrintStream(byteArrayOutputStream));  
		return byteArrayOutputStream.toString();
	}
}
